package com.maxd.respository.article;

import com.maxd.model.ArticleCollect;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.Repository;
import org.springframework.data.repository.query.Param;

public interface ArticleCollectRepository extends Repository<ArticleCollect, Long> {


    @Query(value = "select id from article_collect where article_id=:articleId and user_id=:userId",
    nativeQuery = true)
    Long selectCount(@Param("articleId") Long articleId, @Param("userId") Long userId);


    @Query(value = "select * from article_collect where user_id=:userId",
    countQuery = "select count(*) from article_collect where user_id=:userId",
    nativeQuery = true)
    Page<ArticleCollect> selectArticleCollectList(@Param("userId") Long userId, Pageable pageable);

}